package gameObjects;

import gameObjects.TextureMapping;

import com.jme.math.Vector3f;
import com.jme.renderer.ColorRGBA;
import com.jme.scene.Node;
import com.jme.scene.shape.Box;

public class BuildArena {
	private static BuildArena buildArena;
	private Box floor;
	private Box w1;
	private Box w2;
	private Box w3;
	private Box w4;
	private Box pillar1;
	private Box pillar2;
	private Box pillar3;
	private Box pillar4;
	
	public static BuildArena getInstance()
	{
		if(buildArena==null)
			buildArena = new BuildArena();
		return buildArena;
	}
	
	public Node create()
    {
		TextureMapping   	tsMap;
		new ColorRGBA();
    	Node arena = new Node("ARENA");
    	
    	int i=0;
    	{
	    	floor =  new Box("floor",   new Vector3f(0,i,0),	new Vector3f(127.0f,i,127.0f));
	    	floor.setCastsShadows(true);
	    	w1 = new Box("SOUTH",       new Vector3f(0,i,-1),   new Vector3f(127,i+20,0));
	    	w1.setCastsShadows(true);
	    	w2 = new Box("NORTH",       new Vector3f(0,i,127f),    new Vector3f(127,i+20,128));
	    	w2.setCastsShadows(true);
	    	w3 = new Box("EAST",        new Vector3f(-1,i,0),    new Vector3f(0,i+20,127));
	    	w3.setCastsShadows(true);
	    	w4 = new Box("WEST",        new Vector3f(127,i,0),   new Vector3f(128,i+20,127));
	    	w4.setCastsShadows(true);
	    	
	    	pillar1 = new Box("pillar", new Vector3f(-2,i,-2),   new Vector3f(0,i+64,0));
	    	pillar1.setCastsShadows(false);
	    	pillar2 = new Box("pillar", new Vector3f(130,i,-2),  new Vector3f(127,i+64,0));
	    	pillar2.setCastsShadows(false);
	    	pillar3 = new Box("pillar", new Vector3f(130,i,130), new Vector3f(127,i+64,127));
	    	pillar3.setCastsShadows(false);
	    	pillar4 = new Box("pillar", new Vector3f(-2,i,130),  new Vector3f(0,i+64,127));
	    	pillar4.setCastsShadows(false);
		  	
	    	tsMap = new TextureMapping();
	    	tsMap.setTexture("textures/floor5.png",new Vector3f(127, 127, 1),true);
	    	tsMap.setTextureManager(floor);
	    	
	    	tsMap.setTexture("textures/backdrop.png",new Vector3f(8, 2, 0),true);
	    	tsMap.setTextureManager(w1);
	    	tsMap.setTextureManager(w2);
	    	tsMap.setTextureManager(w3);
	    	tsMap.setTextureManager(w4);
	    	
	    	tsMap.setTexture("textures/red_color.jpg",new Vector3f(1, 1, 1),true);
	    	tsMap.setTextureManager(pillar1);
	    	tsMap.setTextureManager(pillar2);
	    	tsMap.setTextureManager(pillar3);
	    	tsMap.setTextureManager(pillar4);
		  	   
		  	arena.attachChild(floor); 
		  	arena.attachChild(w1);
		  	arena.attachChild(w2);
		  	arena.attachChild(w3);
		  	arena.attachChild(w4);
		  	arena.attachChild(pillar1);
		  	arena.attachChild(pillar2);
		  	arena.attachChild(pillar3);
		  	arena.attachChild(pillar4);
    	}
	  	return arena;
  	}
}
